﻿using System;
using System.Data;
using System.Configuration;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using Cn.Edwon.Web.Ac;
using Cn.Edwon.Web.Session;
using Cn.Edwon.Web;
using System.Reflection;
using Cn.Cellula.Biz;
using Cn.Cellula.Biz.Port;
using Cn.Edwon.Spring;
using Cn.Cellula.Model.Security;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace Cn.Cellula.MiniTopSite {
    public class MyAc:IAuthentication {
        private static Common.Logging.ILog log = Common.Logging.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
        #region IAuthentication 成员

        ISessActor _Actor;
        public ISessActor Actor {
            get {
                return _Actor;
            }
            set {
                _Actor = value;
            }
        }

        public AcState Authenticate(string url) {

            //BEGIN: 自定义判定=====
            //超级管理员优先检查
            if (IsLogined && this.Actor.ID == BizConst.Admin.KEY) {
                log.Debug("AC: Super Admin,passed");
                return AcState.Normal;
            }
            //END ==================

            return AcHelper.Excute(this.Actor, url);
        }

        public bool IsLogined {
            get {
                return (_Actor != null);
            }
        }

        public bool IsAdmin {
            get {
                return (_Actor != null && _Actor.ID.ToLower() == BizConst.Admin.KEY.ToLower());
            }
        }

        #endregion


        public ISessActor RemoteHandler(string rUserKey, string rRacKey) {
            return null;
        }
    }
}
